package com.soft.bams.dao;

import com.soft.bams.entity.Account;

import java.util.ArrayList;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/5/7
 */
public  class ListDao implements IDao<Account, ArrayList<Account>>{
    private ArrayList<Account> accountList=new ArrayList<>();
    private Long id=100000000000000000L;

    @Override
    public Long getId() {
        return this.id;
    }

    @Override
    public void setId(Long id) {
        this.id = id;
    }

    //插入新用户
    public void insert(Account acc) {
        accountList.add(acc);
    }
    //根据ID和密码查询账户
    public Account selectOne(Long id, String pwd) {
        for (int i = 0; i < accountList.size(); i++) {
            Account a = accountList.get(i);
            if (a != null && a.getId().equals(id) && a.getPassword().equals(pwd)) {
                return a;
            }
        }
        return null;
    }
    //根据ID查询数据
    public Account selectOne(Long id) {
        for (Account a : accountList) {
            if (a != null && a.getId().equals(id)) {
                return a;
            }
        }
        return null;
    }
    public ArrayList<Account> selectAll() {
        return accountList;
    }
}